const tranListToTreeData = arr => {
  // 创建一个字典（一个对象）让 "id":{}
  const obj = {}
  const newArr = []
  arr.forEach(item => {
    item.children = []
    obj[item.id] = item
  })
  arr.forEach(i => {
    const p = obj[i.pid]
    if (p) {
      // obj[p].children = i
      p.children.push(i)
    } else {
      newArr.push(i)
    }
  })
  return newArr
}
export { tranListToTreeData }
